<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->unsignedBigInteger('assistant_type_id')->nullable();
        });

        $defaultType = \App\Models\AssistantType::create([
            'name' => '默认',
            'sort' => 0,
        ]);
        \App\Models\User::withType(\App\Enums\UserType::Assistant)->update([
            'assistant_type_id' => $defaultType->id,
        ]);
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('users', function (Blueprint $table) {
            //
        });
    }
};
